package org.rambadger.command.event;


import org.rambadger.command.model.SubmissionEntity;
import org.rambadger.command.validation.UrlIdentifier;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

public class ReviewFinalized implements Serializable {
    private static final long serialVersionUID = -1941936355525827857L;

    //Compound Key {
    private final String submitterId;
    private final int submissionId;
    //}

    private final String reviewerId;

    private final int submissionPointsAwarded;
    private final int reviewPointsAwarded;

    private final SubmissionEntity.ReviewOutcome outcome;

    public ReviewFinalized(String submitterId, int submissionId, String reviewerId, int submissionPointsAwarded, int reviewPointsAwarded, SubmissionEntity.ReviewOutcome outcome) {
        this.submitterId = submitterId;
        this.submissionId = submissionId;
        this.reviewerId = reviewerId;
        this.submissionPointsAwarded = submissionPointsAwarded;
        this.reviewPointsAwarded = reviewPointsAwarded;
        this.outcome = outcome;
    }

    @UrlIdentifier @NotNull
    public String getSubmitterId() {
        return submitterId;
    }

    @Min(1)
    public int getSubmissionId() {
        return submissionId;
    }

    @UrlIdentifier @NotNull
    public String getReviewerId() {
        return reviewerId;
    }

    @Min(0)
    public int getSubmissionPointsAwarded() {
        return submissionPointsAwarded;
    }

    @Min(0)
    public int getReviewPointsAwarded() {
        return reviewPointsAwarded;
    }

    @NotNull
    public SubmissionEntity.ReviewOutcome getOutcome() {
        return outcome;
    }


    public String getFullSubmissionId() {
        return submitterId+"/"+submissionId;
    }

    @Override
    public String toString() {
        return "ReviewFinalized{" +
                "submitterId='" + submitterId + '\'' +
                ", submissionId=" + submissionId +
                ", reviewerId='" + reviewerId + '\'' +
                ", submissionPointsAwarded=" + submissionPointsAwarded +
                ", reviewPointsAwarded=" + reviewPointsAwarded +
                ", outcome=" + outcome +
                '}';
    }
}
